import request from "./request";

export async function findAllForFirstLevel() {
  return request("/archive/findAllForFirstLevel", { method: 'post' });
}

// 获取当前资源所有文件
export async function findAllFolder(parentId) {
  return request('/archiveFolder/findAllFolder', {
    method: 'post',
    data: {
      parentId
    }
  })
}

// 获取文件夹 及 文件
export async function findByPage(params) {
  let paramsData = `page=${params.page}&limit=${params.limit}&folderFlag=${params.folderFlag}&parentId=${params.parentId}`;
  if (params.folderFlag * 1 === 1) {
    paramsData += `&keyword=${params.keyword}`;
    if (params.fileName) {
      paramsData += `&fileName=${params.fileName}`;
    }
    if (params.hasTags) {
      paramsData += `&hasTags=${params.hasTags}`;
    }
  }
  return request(`/archive/findByPage?${paramsData}`);
}

// 获取数量
export async function queryCount() {
  return request('/archive/queryCount', {method: 'post'});
}

// 回收站文件夹数据
export async function queryAllFolderDelete() {
  return request('/archiveFolder/queryAllDeleteList1', {method: 'post'})
}

// 回收站文件数据
export async function queryAllFileDelete() {
  return request('/archiveFolder/queryAllDeleteList2', {method: 'post'})
}

// 单个文件详细信息
export async function queryFileDetail (params) {
  return request('/archive/findById', {
    method: 'post',
    data: params
  })
}
// 查询文件标签
export async function queryFileTags (params) {
  return request('/archiveProperty/queryByArchiveId', {
    method: 'post',
    data: params
  })
}
// 删除文件标签
export async function deleteFileTag(params) {
  return request('/archiveProperty/deleteByIds', {
    method: 'post',
    data: params
  })
}

// 删除文件

export async function batchDelete(params) {
  return request('/archive/batchDelete', {
    method: 'post',
    data: params
  })
}

// 清空回收站
export async function batchDeleteComplete(params){
  return request('/archiveFolder/batchDeleteComplete', {
    method: 'post',
    data: params
  })
}
// 还原回收站内容

export async function batchRestore(params) {
  return request('/archiveFolder/batchRestore', {
    method: 'post',
    data: params
  })
}

// 删除资源文件
export async function deleteSource(params) {
  return request('/archiveFolder/delete', {
    method: 'post',
    data: params
  })
}

// 添加资源库
export async function saveResource(params) {
  return request('/archiveFolder/save', {
    method: 'post',
    data: params
  })
}
// 文件信息更新

export async function updateFileDetail(params) {
  return request('/archive/batchUpdateSelect', {
    method: 'post',
    data: params
  })
}

// 备注更新
export async function updateRemarks(params) {
  return request('/archive/updateForRemark', {
    method: 'post',
    data: params
  })
}
// 新建文件夹
export async function addFolderRequest(params) {
  return request('/archiveFolder/save', {
    method: 'post',
    data: params
  })
}
// 文件上传
export async function batchUploadFile(params) {
  return request('/batchUploadHasInfo', {
    method: 'post',
    data: params,
  })
}

// 获取所有筛选
export async function findById() {
  return request('/website/findById', {
    method: 'post',
    data: {
      id: '1'
    }
  })
}

// 更新搜索设置
export async function updateSearchSet(params) {
  return request('/website/updateConfig3', {
    method: 'post',
    data: {...params, id: '1'}
  })
}

// 获取所有标签
export async function getAllTags() {
  return request('/property/findAll', {method: 'post'});
}

export async function updateConfig2(params){
  return request('/website/updateConfig2', {
    method: 'post',
    data: {...params, id: '1'}
  })
}

// 上传缩略图 预览图
export async function updateOnlyImg(params) {
  return request('/archive/updateOnlyImg', {
    method: 'post',
    data: params
  })
}

// 保存标签
export async function saveTags(params) {
  return request('/archiveProperty/batchSave', {
    method: 'post',
    data: params
  })
}


